﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace CRM
{
    public partial class UserPowerManage : System.Web.UI.Page
    {
        protected override void OnPreLoad(EventArgs e)
        {
            Common.CheckMes.CheckState("User_ID", "Index.aspx", "用户登录信息丢失，请重新登录...");
            string PowerMes = Common.EncryptString.DeMyEnncrypt(Common.GetMes.GetCookies("Power_Mes"), 6);

            if (PowerMes.IndexOf("2_3") < 0)
            {
                Common.MessageBox.Show(Page, "你没有编辑的权限...", "Body.aspx", "BACK");
            }
            base.OnPreLoad(e);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }

        private void LoadData()
        {
            RpPowerUser.DataSource = BLL.ServiceUser.GetPowerInfo("");
            RpPowerUser.DataBind();
        }

        protected void RpPowerUser_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName=="Del")
            {
                if (!string.IsNullOrEmpty(e.CommandArgument.ToString()))
                {
                    if (BLL.ServiceUser.DelPowerInfo(e.CommandArgument.ToString()))
                    {
                        //留着写日志

                        Common.MessageBox.Show(Page, "角色信息成功删除..", "UserPowerManage.aspx", "suess");
                    }
                    else
                    {
                        Common.MessageBox.Show(Page, "角色信息删除失败，请重试或联系技术人员..", "error");
                    }
                }
            }
        }
    }
}
